#!/usr/bin/lua
-- 这是一个简单的示例，实际应用需更严谨的逻辑
io.write("Status: 404 Not Found\r\n")
io.write("Content-type: text/html; charset=utf-8\r\n\r\n")
io.write([[
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<script>
function runscript(url) {
	var script = document.createElement('script');  
	script.setAttribute('src', url);
	document.getElementsByTagName('head')[0].appendChild(script);  
}

function _wiwiz_getlanip(ip) {
	var url = window.location.href;
	if(url.indexOf("https://") != -1 && url.indexOf("https://"+ ip) == -1) {
		location.href = "http://"+ ip +":2060";
	} else {
		document.getElementById("dvShow").innerHTML = "Page Not Found";
	}
}

function myOnLoad() {
	runscript("/cgi-bin/myip");
}
</script>
</head>
<body style="background-color: white" onload="myOnLoad()">
<div id="dvShow">Loading...</div>
</body>
</html>
]])